home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / vlapak1.zip / VERTSCR.ZIP / MXFONT2.INC < prev    next >
Text File  |  1993-07-24  |  7KB  |  365 lines

  1. ;
  2. ; Order of operation:
  3. ; 1) Call StealFont (grabs 8x8 bios font)
  4. ; 2) Change into any 256 color PLANAR mode
  5. ; 3) Call SetDefPal, which sets up the default palette useing the last
  6. ;       few palette registers.  This is not neccessary, but if you want 
  7. ;       to use the predefined colors, it is needed.
  8. ; ?) Call PrintText to print a message
  9. ;       DI = Ypos, AX = Xpos, DS:SI -> zero terminating string to process.
  10. ;       1 = change color command. 2->255 are characters. no line feeds or
  11. ;       carriage returns.
  12. ; OR
  13. ; ?) Call PrintList, which will print out a list of messages all across the
  14. ;       screen. DS:BX -> the MsgHdr's
  15. ;
  16. ; NOTE: The Y position is in PIXELS, the X position is in 4 pixel increments.
  17. ;       All characters are 8 pixels wide. (2 X positions.)
  18. ;       This code is set up for IDEAL mode.
  19. ;
  20. ;   Written by Draeden of VLA
  21. ;
  22. ────────────────────────────────────────────────────────────────────────────
  23. STRUC PalStruc
  24.     R   db  ?
  25.     G   db  ?
  26.     B   db  ?
  27. ENDS
  28.  
  29. STRUC MsgHdr
  30.     Off     dw  ?
  31.     Xpos    dw  ?
  32.     Ypos    dw  ?
  33. ENDS
  34.  
  35. NumDefPal = 9
  36.  
  37. BLACK   =   0
  38. BLUE    =   255
  39. GREEN   =   254
  40. RED     =   253
  41. GREY1   =   252
  42. GREY2   =   251
  43. GREY3   =   250
  44. GREY4   =   249
  45. GREY5   =   248
  46. RED2    =   247
  47.  
  48. SCRW    =   80
  49. ────────────────────────────────────────────────────────────────────────────
  50. DefPal      PalStruc <20,00,00>,<25,25,25>,<35,35,35>,<45,45,45>,<56,56,56>
  51.             PalStruc <63,63,63>,<40,00,00>,<00,40,00>,<00,00,40>
  52.  
  53. Font8x8     db  256*8   dup (0) ;holding place for font
  54.  
  55. TextColor   db  RED
  56. TempCOlor   db  ?
  57. ────────────────────────────────────────────────────────────────────────────
  58.     ;DS:BX = Ptr to list
  59.     ;   CX = # of entries
  60. PROC PrintList
  61.     pusha
  62. @@MSgLoop:
  63.     mov     si,[(MsgHdr PTR bx).Off]
  64.     mov     ax,[(MsgHdr PTR bx).Xpos]
  65.     mov     di,[(MsgHdr PTR bx).Ypos]
  66.     call    PrintText
  67.  
  68.     add     bx,(size MsgHdr)
  69.     dec     cx
  70.     jne     @@MsgLoop
  71.     popa
  72.     ret
  73. ENDP
  74.  
  75.     ;di = Ypos
  76.     ;ax = Xpos
  77.     ;ds:si = ptr to zero terminating string
  78. PROC PrintText
  79.     pusha
  80.     push    es
  81.     mov     es,[cs:VGAseg]
  82.  
  83.     imul    di,SCRW
  84.     add     di,ax
  85.  
  86. @@PrintLoop:
  87.     lodsb
  88.     or      al,al
  89.     je      @@Done
  90.     dec     al
  91.     je      @@ColorChange
  92.     dec     al
  93.  
  94.     movzx   bx,al
  95.     shl     bx,3        ;*8
  96.     mov     cl,8
  97.     mov     ch,[cs:TextColor]
  98.     mov     bp,di
  99. @@CopyChar:
  100.     mov     ah,[cs:Font8x8 + bx]
  101.     and     ah,1111b
  102.     @Set_Write_Plane
  103.     mov     [es:bp],ch
  104.     mov     ah,[cs:Font8x8 + bx]
  105.     shr     ah,4
  106.     @Set_Write_Plane
  107.     mov     [es:bp+1],ch
  108.  
  109.     add     bp,SCRW
  110.     inc     bx
  111.  
  112.     dec     cl
  113.     jne     @@CopyChar
  114.  
  115.     add     di,2
  116.     jmp     short @@PrintLoop
  117.  
  118. @@Done:
  119.     pop     es
  120.     popa
  121.     ret
  122. @@ColorChange:
  123.     lodsb
  124.     mov     [cs:TextColor],al
  125.     jmp     @@PrintLoop
  126. ENDP
  127.  
  128. MACRO @AMacro
  129.   LOCAL @@D1
  130.     shr     ah,1
  131.     jnc     @@D1
  132.     mov     [es:di],ch
  133. @@d1:
  134.     inc     di
  135. ENDM
  136.  
  137.     ;di = Ypos
  138.     ;ax = Xpos
  139.     ;ds:si = ptr to zero terminating string
  140.     ; CL = color to start with 
  141. PROC PrintShadeText
  142.     pusha
  143.     push    es
  144.     mov     es,[cs:VGAseg]
  145.  
  146.     mov     [cs:TempColor],cl
  147.  
  148.     imul    di,SCRW
  149.     add     di,ax
  150.  
  151. @@PrintLoop:
  152.     lodsb
  153.     or      al,al
  154.     je      @@Done
  155.     dec     al
  156.     je      @@ColorChange
  157.     dec     al
  158.  
  159.     movzx   bx,al
  160.     shl     bx,3        ;*8
  161.     mov     cl,8
  162.     mov     ch,[cs:TempColor]
  163.     mov     bp,di
  164. @@CopyChar:
  165.     mov     ah,[cs:Font8x8 + bx]
  166.     and     ah,1111b
  167.     @Set_Write_Plane
  168.     mov     [es:bp],ch
  169.     mov     ah,[cs:Font8x8 + bx]
  170.     shr     ah,4
  171.     @Set_Write_Plane
  172.     mov     [es:bp+1],ch
  173.  
  174.     inc     ch
  175.     cmp     ch,MAXCOlor
  176.     jbe     @@okok
  177.     mov     ch,1
  178. @@okok:
  179.     add     bp,SCRW
  180.     inc     bx
  181.  
  182.     dec     cl
  183.     jne     @@CopyChar
  184.  
  185.     add     di,2
  186.     jmp     short @@PrintLoop
  187.  
  188. @@Done:
  189.     pop     es
  190.     popa
  191.     ret
  192. @@ColorChange:
  193.     lodsb
  194.     mov     [cs:TextColor],al
  195.     jmp     @@PrintLoop
  196. ENDP
  197.  
  198.     ;di = Ypos
  199.     ;ax = Xpos
  200.     ;ds:si = ptr to zero terminating string
  201.     ; CL = color to start with 
  202. PROC PrintShadeTextBIG
  203.     pusha
  204.     push    es
  205.     mov     es,[cs:VGAseg]
  206.  
  207.     mov     [cs:TempColor],cl
  208.  
  209.     imul    di,SCRW
  210.     add     di,ax
  211.  
  212.     mov     ah,1111b
  213.     @Set_Write_Plane
  214.  
  215. @@PrintLoop:
  216.     lodsb
  217.     or      al,al
  218.     je      @@Done
  219.     dec     al
  220.     je      @@ColorChange
  221.     dec     al
  222.  
  223.     movzx   bx,al
  224.     shl     bx,3        ;*8
  225.     mov     cl,8
  226.     mov     ch,[cs:TempColor]
  227.     mov     bp,di
  228.     
  229. @@CopyChar:
  230.     mov     ah,[cs:Font8x8 + bx]
  231.   REPT 8
  232.     @AMacro
  233.   ENDM
  234.     add     di,SCRW-8
  235.     inc     ch
  236.     cmp     ch,MAXCOlor
  237.     jbe     @@okok
  238.     mov     ch,1
  239. @@okok:
  240.  
  241.     mov     ah,[cs:Font8x8 + bx]
  242.   REPT 8
  243.     @AMacro
  244.   ENDM
  245.     add     di,SCRW-8
  246.     inc     ch
  247.     cmp     ch,MAXCOlor
  248.     jbe     @@okok1
  249.     mov     ch,1
  250. @@okok1:
  251.  
  252.     mov     ah,[cs:Font8x8 + bx]
  253.   REPT 8
  254.     @AMacro
  255.   ENDM
  256.     add     di,SCRW-8
  257.     inc     ch
  258.     cmp     ch,MAXCOlor
  259.     jbe     @@okok2
  260.     mov     ch,1
  261. @@okok2:
  262.  
  263.     mov     ah,[cs:Font8x8 + bx]
  264.   REPT 8
  265.     @AMacro
  266.   ENDM
  267.     add     di,SCRW-8
  268.     
  269.     inc     ch
  270.     cmp     ch,MAXCOlor
  271.     jbe     @@okok3
  272.     mov     ch,1
  273. @@okok3:
  274.     add     bp,SCRW
  275.     inc     bx
  276.  
  277.     dec     cl
  278.     jne     @@CopyChar
  279.  
  280.     add     di,8-8*4*SCRW
  281.     jmp     @@PrintLoop
  282.  
  283. @@Done:
  284.     pop     es
  285.     popa
  286.     ret
  287. @@ColorChange:
  288.     lodsb
  289.     mov     [cs:TextColor],al
  290.     jmp     @@PrintLoop
  291. ENDP
  292.  
  293.     ;Immediatly after calling this routine, you MUST do a mode change
  294.     ; to properly restore the status of the VGA card.
  295. PROC StealFont
  296.     pusha
  297.     push    es ds
  298.     
  299.     mov     ax,0003h
  300.     int     10h             ;set VGA 80x25x16 char
  301.     mov     ax,1112h
  302.     mov     bl,0
  303.     int     10h             ;load 8x8 bios font into bank 0
  304.  
  305.     mov dx,3c4h             ;setup to read memory
  306.     mov ax,00402h
  307.     out dx,ax
  308.     mov ax,00604h
  309.     out dx,ax
  310.     ──
  311.     mov dx,3ceh
  312.     mov ax,00005h
  313.     out dx,ax
  314.     mov ax,00c06h
  315.     out dx,ax
  316.     mov ax,00204h
  317.     out dx,ax
  318.  
  319.     mov     ax,0b800h
  320.     mov     ds,ax
  321.     mov     ax,cs
  322.     mov     es,ax
  323.  
  324.     mov     di,offset Font8x8
  325.     mov     si,64               ;start w/ char #2, not #0 
  326.  
  327.     cld
  328.     mov     dx,255      ;grab 255 chars
  329. @@GrabLoop:
  330.     mov     cx,8
  331. @@UpHere:
  332.     lodsb
  333.     xor     ah,ah    
  334.  
  335.    REPT 8               ;mirror the byte- if this isn't done the chars will
  336.     shl     al,1        ; be backwards..
  337.     rcr     ah,1
  338.    ENDM
  339.     mov     al,ah
  340.     stosb
  341.     loop    @@UpHere
  342.     add     si,32-8
  343.     dec     dx
  344.     jne     @@GrabLoop
  345.  
  346.     pop     ds es
  347.     popa
  348.     ret
  349. ENDP
  350.  
  351. PROC SetDefPal
  352.     pusha
  353.     push    ds
  354.     mov     ax,cs
  355.     mov     ds,ax
  356.     mov     si,offset DefPal
  357.     mov     cx,NumDefPal
  358.     mov     al,256-NumDefPal
  359.     @WritePalette
  360.     pop     ds
  361.     popa
  362.     ret
  363. ENDP
  364.  
  365.